<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

<div id="app">
    姓：<input type="text" v-model="surname"><br>
    名：<input type="text" v-model="name"><br>
    <p>姓名：{{fullName}}</p>
    <button @click="update">修改姓名</button>
</div>
<script src="../lib/vue.js"></script>
<script>
    const app = new Vue({
        el: '#app',
        data: {
            surname: '',
            name: ''
        },
        computed: {
            fullName: {
                get() {
                    return this.surname + this.name;
                },
                set(value) {
                    this.surname = value.substring(0, 1);
                    this.name = value.substring(1);
                }
            }
        },
        methods: {
            update() {
                this.fullName = '张艺';
            }
        }
    })
</script>
</body>
</html>